package com.example.project.service.impl;

import com.example.project.dao.IAttendanceDao;
import com.example.project.entity.Attendance;
import com.example.project.service.IAttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AttendanceServiceImpl implements IAttendanceService {
    @Autowired
    private IAttendanceDao attendanceDao;

    @Override
    public int add(Attendance attendance) {

        return attendanceDao.add(attendance);
    }

    @Override
    public List<Attendance> getAllAttendance(Attendance attendance) {
        return attendanceDao.getAllAttendance(attendance);
    }

    @Override
    public int deleteAttendance(Attendance attendance) {
        int attendanceValue=0;
        if (attendance.getAttendanceId()!=0){
            attendanceValue=attendanceDao.deleteAttendance(attendance);
        }
        return attendanceValue;
    }

    @Override
    public int updateAttendance(Attendance attendance) {
        int attendanceValus=0;
        if (attendance.getAttendanceId()!=0){
            attendanceValus=attendanceDao.updateAttendance(attendance);
        }
        return attendanceValus;
    }

    //实现单挑查询打卡数据方法
    @Override
    public Attendance getAttendance(Attendance attendance) {
        Attendance attendance1=new Attendance();
        if(attendance.getAttendanceId()!=0){
            attendance1=attendanceDao.getAttendance(attendance);
        }
        return attendance1;
    }
}
